package Aleehot100;

import java.util.Stack;

/**
 * ClassName: c070
 * Package: Aleehot100
 * Description: 155. 最小栈
 *
 * @Author BCXJ
 * @Create 2025/8/17 09:49
 * @Version 1.0
 * @Since 1.0
 */
public class c070 {
    public static void main(String[] args) {

    }

    static class MinStack {
        Stack<Integer> stack = new Stack<>();
        Stack<Integer> minStack = new Stack<>();

        public MinStack() {

        }

        public void push(int val) {
            stack.push(val);
            if (minStack.isEmpty() || val < minStack.peek()) {
                minStack.push(val);
            } else {
                minStack.push(minStack.peek());
            }
        }

        public void pop() {
            minStack.pop();
            stack.pop();
        }

        public int top() {
            return stack.peek();
        }

        public int getMin() {
            return minStack.peek();
        }

    }
}
